import request from '@/utils/request'

// 隐私条款相关接口
export function updatePrivacyClause(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request.post('/management/system/text/updatePrivacyClause', formData)
}

export function getPrivacyClause() {
  return request.get('/management/system/text/getPrivacyClause')
}

// 数据文档相关接口
export function addDataDocument(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request.post('/management/system/text/add', formData)
}

export function deleteDataDocument(id) {
  return request.delete('/management/system/text/delete', null, {
    params: { id }
  })
}

// 操作指南相关接口
export function getInstructionsList() {
  return request.get('/management/system/text/instructions/list')
}

export function getInstructionDetail(id) {
  return request.get('/management/system/text/instructions/detail', {
    params: { id }
  })
}

export function addInstruction(data) {
  const formData = new FormData()
  formData.append('title', data.title)
  formData.append('content', data.content)
  if (data.image) {
    formData.append('image', data.image)
  }
  return request.post('/management/system/text/instructions/add', formData)
}

export function updateInstruction(data) {
  const formData = new FormData()
  formData.append('id', data.id)
  formData.append('title', data.title)
  formData.append('content', data.content)
  if (data.image) {
    formData.append('image', data.image)
  }
  return request.put('/management/system/text/instructions/update', formData)
}

export function deleteInstruction(id) {
  return request.delete('/management/system/text/instructions/delete', null, {
    params: { id }
  })
}
